package hafnium.bukkit.pail.pipe.plugins;

import hafnium.bukkit.pail.pipe.PailPipe;
import hafnium.bukkit.pail.pipe.logging.PPLogger;

import org.bukkit.plugin.java.JavaPlugin;

public abstract class PailPlugin extends JavaPlugin {
	private PipeProxy pipe;
	private PPLogger logger;

	/**
	 * Called by bukkit when this SubPail is being disabled.
	 */
	public final void onDisable() {
		this.logger.log("Disabling...");

		this.onDisable_P();

		this.logger.log("Disabled.");
	}

	/**
	 * Called by bukkit when this SubPail is being enabled.
	 */
	public final void onEnable() {
		pipe = PailPipe.instance.register(this);
		logger = pipe.getLogger();

		this.logger.log("Enabling...");

		this.onEnable_P();

		this.logger.log("Enabled.");
	}

	/**
	 * Called while this SubPail is being enabled to allow it to initialize
	 * itself.
	 */
	public abstract void onEnable_P();

	/**
	 * Called while this SubPail is being disabled to allow it to finalize
	 * itself.
	 */
	public abstract void onDisable_P();
	
	public void log(String message) {
		this.logger.log(message);
	}
}
